home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / lightwave / lwmlist / 93.lightwave-00 / 000644_rutgers!well.sf.ca.us!shf_Tue, 10 Aug 93 12:46:12 EDT.msg < prev    next >
Internet Message Format  |  1993-12-31  |  3KB

  1. Received: by bobsbox.rent.com (V1.16/Amiga)
  2.     id AA00000; Tue, 10 Aug 93 12:46:12 EDT
  3. Received: from nkosi.well.sf.ca.us by rutgers.edu (5.59/SMI4.0/RU1.5/3.08) 
  4.     id AA29623; Tue, 10 Aug 93 04:03:44 EDT
  5. Received: from well.sf.ca.us (well.sf.ca.us [192.132.30.2]) by nkosi.well.sf.ca.us (8.5/8.5) with SMTP id BAA04606; Tue, 10 Aug 1993 01:03:40 -0700
  6. Received: by well.sf.ca.us id <14046-2>; Tue, 10 Aug 1993 01:03:10 -0700
  7. Message-Id: <93Aug10.010310pdt.14046-2@well.sf.ca.us>
  8. Date:     Tue, 10 Aug 1993 01:03:10 -0700
  9. From: "Stuart H. Ferguson" <rutgers!well.sf.ca.us!shf>
  10. To: bobsbox.rent.com!lightwave
  11. Subject: Conform to Sphere script
  12.  
  13. Having been challenged by Imagine's "Conform to Sphere" operation, I
  14. sat down and wrote an ARexx script for Modeler 3.0 that does a 
  15. similar function.  I only spent a few minutes on it, so it does not
  16. have a lot of bells and whistles, but it does do essentially the 
  17. desired transformation.  Hope this helps the fellow who wanted to
  18. do this ...
  19.  
  20.     Stuart Ferguson
  21. -----------------------
  22.  
  23. /*
  24.  * Wrap Data onto Sphere -- Modeler ARexx transform.
  25.  *
  26.  * 8/93  Stuart Ferguson
  27.  */
  28.  
  29.     mxx="LWModelerARexx.port"
  30.     signal on error
  31.     signal on syntax
  32.     check = addlib("rexxmathlib.library",0,-30,0)
  33.     mxx_add = addlib(mxx,0)
  34.     call main
  35.     if (mxx_add) then call remlib(mxx)
  36.     exit
  37.  
  38.     syntax:
  39.     error:
  40.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  41.     if (mxx_add) then call remlib(mxx)
  42.     exit
  43.  
  44.  
  45. main:
  46.  
  47. syscode = "Wrap Sphere"
  48.  
  49.  
  50. /* Get size and thickness of sphere from user.
  51.  */
  52. call req_begin syscode
  53.  
  54. id_inr = req_addcontrol("Inner Radius", 'n', 1)
  55. id_otr = req_addcontrol("Outer Radius", 'n', 1)
  56. id_sel = req_addcontrol("Points", 'c', 'All Selected')
  57. call req_setval id_inr, 1.0, 1.0
  58. call req_setval id_otr, 2.0, 2.0
  59. call req_setval id_sel, 2
  60.  
  61. if (~req_post()) then return
  62.  
  63. r1 = req_getval(id_inr)
  64. r2 = req_getval(id_otr)
  65. call sel_mode word('global user',req_getval(id_sel))
  66.  
  67. call req_end
  68.  
  69.  
  70. /* Get extent of data area.  This will just take the extent in
  71.  * X and Y and map it to lat and long on the sphere, and the
  72.  * extent in Z and map it to r1 and r2.
  73.  */
  74. parse value boundingbox() with n x1 x2 y1 y2 z1 z2 .
  75. dx = x2 - x1
  76. dy = y2 - y1
  77. dz = z2 - z1
  78. if (n <= 0 | dx <= 0 | dy <= 0) then return
  79. d2r = 3.1415926 / 180
  80.  
  81. /* Transform loop
  82.  */
  83. n = xfrm_begin()
  84. call meter_begin n, syscode
  85. do i = 1 to n
  86.     parse value xfrm_getpos(i) with x y z .
  87.  
  88.     lat = d2r * ((y - y1) / dy * 180 - 90)
  89.     lon = d2r * ((x - x1) / dx * 360)
  90.     if (dz <= 0) then rad = r1
  91.                  else rad = (z - z1) / dz * (r2 - r1) + r1
  92.  
  93.     y = rad * sin(lat)
  94.     p = rad * cos(lat)
  95.     x = p * sin(lon)
  96.     z = p * cos(lon)
  97.  
  98.     call xfrm_setpos i, x y z
  99.     call meter_step
  100. end
  101. call meter_end
  102. call xfrm_end
  103.  
  104. return
  105. ------------------------- end